
import java.util.LinkedList;

public class WarGame {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new WarGame();
	}

	private LinkedList<String> ali = new LinkedList<String>();
	private LinkedList<String> bob = new LinkedList<String>();

	/**
	 * Constructor
	 */
	public WarGame() {

		//deal cards
		deal();

		//Play a game of war!
		playGame();

	}

	/**
	 * Play a game of war
	 */
	private void playGame() {
		//Take turns untill somebody wins
		int k = 0;
		for (k = 0; k < 100000; k++) {
			//Take turn
			if (turn()) {
				break;
			}
		}

		if (k == 100000)
			System.out.println("Draw!");

	}

	/**
	 * Deal the cards
	 */
	private void deal() {
                int count = StdIn.readInt();
            for(int i=0 ;i < count; i++) {
                ali.add(StdIn.readString());
            }
            for(int i=0 ;i< count; i++) {
                bob.add(StdIn.readString());
            }
	}

	/**
	 * Take a turn
	 */
	private boolean turn() {

		//The depth of the war
		int i = 0;

		//The cards in play
		String aliCard;
		String bobCard;
		String winnerCard;

		//Compare cards until somebody wins the game or the turn
		while(true) {

			aliCard = null;
			bobCard = null;
			winnerCard = null;

			if (i < ali.size()) {
				aliCard = ali.get(i);
			}

			if (i < bob.size()) {
				bobCard = bob.get(i);
			}

			winnerCard = compare(aliCard,bobCard);

			if (winnerCard == null) {
				i+=2;
			}else{
				break;
			}
		}

		//The turn is over, the winner loots
		if (winnerCard == bobCard) {
			loot(bob, i);
		}else{
			loot(ali, i);
		}

		//Check for win
		return checkForWin();
	}

	/**
	 * Check for win
	 */
	private boolean checkForWin() {
		//Check if somebody has won
		if (bob.isEmpty()) {
			System.out.println("Ali wins");
			return true;
		}

		if (ali.isEmpty()) {
			System.out.println("Bob wins");
			return true;
		}
		return false;
	}



	/**
	 * Loot
	 */
	private void loot(LinkedList<String> winner,int depth) {
		for(int j = 0; j<= depth; j++) {
			if ((j < ali.size())&&(j < bob.size())) {
				winner.add(ali.pop());
				winner.add(bob.pop());
			}else{
				break;
			}
		}
	}


	/**
	 *Compare two cards
	 *@return the winner, if draw, returns null
	 */
	private String compare(String aliCard, String bobCard) {

		if (value(aliCard) > value(bobCard)) {
			return aliCard;
		}

		if (value(bobCard) > value(aliCard)) {
			return bobCard;
		}

		return null;
	}

	/**
	 * Calculate value of a card
	 */
	private int value(String card) {

		int value = 0;

		if (card != null) {
			String subS = card.substring(0,1);
			value = 0;
			if (subS.equals("A")) {value = 1;};
			if (subS.equals("T")) {value = 10;};
			if (subS.equals("J")) {value = 11;};
			if (subS.equals("Q")) {value = 12;};
			if (subS.equals("K")) {value = 13;};
			if (value == 0) {
				value = Integer.parseInt(subS);
			}
		}
		return value;
	}

}
